Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for repeating previous/next commands #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Apr 13, 2018

This is useful for mapping it to something convenient like üü and ++
on a German keyboard layout, allowing for context-sensitive movement by
default (e.g. forwarding to [c, ]c in diff mode), and remembering
the last used command group.

Other plugins are able to hook into this by setting
b:unimpaired_prevnext.

@@ -36,8 +36,9 @@ function! s:MapNextFamily(map,cmd) abort
let map = '<Plug>unimpaired'.toupper(a:map)
let cmd = '".(v:count ? v:count : "")."'.a:cmd
let end = '"<CR>'.(a:cmd == 'l' || a:cmd == 'c' ? 'zv' : '')
execute 'nnoremap <silent> '.map.'Previous :<C-U>exe "'.cmd.'previous'.end
execute 'nnoremap <silent> '.map.'Next :<C-U>exe "'.cmd.'next'.end
let prevnext = printf('["\%sPrevious", "\%sNext"]', map, map)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not really need to be a list, but having a list for b:unimpaired_prevnext makes sense.

@blueyed
Copy link
Contributor Author

blueyed commented Sep 1, 2018

@tpope
What do you think about this in general?
Would be happy to rebase it.

This is useful for mapping it to something convenient like `üü` and `++`
on a German keyboard layout, allowing for context-sensitive movement by
default (e.g. forwarding to `[c`, `]c` in diff mode), and remembering
the last used command group.

Other plugins are able to hook into this by setting `g:unimpaired_prevnext`.

It uses `:normal` in g:unimpaired_prevnext explicitly.  This allows to
specify the whole command for `:exe`, and does not require a mapping.

The mapping is used internally to handle the `zv`, but that could be
included in the command already now.

It uses the `g:` namespace, which is important for repeating `[q/]q`
across buffers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant